home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / X / Xserver / crosshair.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.8 KB  |  56 lines

  1. /*
  2.  * Copyright 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /* compile: cc -o crosshair crosshair.c -lX11_s -lsun */
  18.  
  19. #include <X11/Xlib.h>
  20. #include <X11/Xatom.h>
  21. #include <stdio.h>
  22.  
  23. main(argc, argv)
  24. int argc;
  25. char *argv[];
  26. {
  27.    Display *display;
  28.    Window root;
  29.    Atom crosshair_prop, atom_type;
  30.    int rc, format;
  31.    unsigned long nitems, remaining;
  32.    XID *value;
  33.  
  34.    display = XOpenDisplay(NULL);
  35.    if(display == NULL) {
  36.       fprintf(stderr, "crosshair: cannot open display %s\n",
  37.          XDisplayName(NULL));
  38.       exit(1);
  39.    }
  40.    crosshair_prop = XInternAtom(display, "_SGI_CROSSHAIR_CURSOR", True);
  41.    if(crosshair_prop == None) {
  42.       fprintf(stderr, "crosshair: could not intern _SGI_CROSSHAIR_CURSOR\n");
  43.       exit(1);
  44.    }
  45.    root = DefaultRootWindow(display);
  46.    rc = XGetWindowProperty(display, root, crosshair_prop, 0L, 1L, False,
  47.       XA_CURSOR, &atom_type, &format, &nitems, &remaining,
  48.       (unsigned char *) &value);
  49.    if(rc != Success) {
  50.       fprintf(stderr, "crosshair: XGetWindowProperty failed\n");
  51.       exit(1);
  52.    }
  53.    XDefineCursor(display, root, value[0]);
  54.    XCloseDisplay(display);
  55. }
  56.